package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.FenceAlarm;
import com.topnav.mc.admin.entity.bean.FenceAlarmBean;
import com.topnav.mc.admin.entity.bean.FencePolygonBean;
import com.topnav.mc.admin.entity.param.FenceAlarmParam;
import com.topnav.mc.admin.entity.param.FencePolygonParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: kenny
 * @Date: 2023/11/13 11:24
 */
@Mapper
public interface FenceAlarmMapper extends McMapper<FenceAlarm, FenceAlarmBean, FenceAlarmParam> {
    String commSql = " SELECT fa.*," +
            " f.fence_name AS fenceName," +
            " o.code AS orgCode, o.name AS orgName, o.short_name AS shortName, o.path," +
            " d.code AS deviceCode, d.name AS deviceName, " +
            " u.code AS userCode, u.name AS userName  " +
            " FROM mc_fence_alarm fa " +
            " LEFT JOIN mc_fence f ON fa.fence_id = f.id " +
            " LEFT JOIN mc_device d  ON fa.device_id = d.id " +
            " LEFT JOIN mc_organization o ON f.org_id = o.id " +
            " LEFT JOIN mc_user u ON d.user_id = u.id " +
            " ${ew.customSqlSegment}";

    @Select(commSql)
    FenceAlarmBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<FenceAlarmBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<FenceAlarmBean> selectInfoPage(Page<FenceAlarmParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);

}
